# Maintainer: Dekedro <dekedro@protonmail.com>
pkgname=openjfx
pkgver=21.0.3_p1 # latest LTS
pkgrel=0
pkgdesc="Client application platform for desktop, mobile and embedded systems built on Java"
url="https://openjfx.io/"
# aarch64: java broken
arch="x86_64"
license="GPL-2.0-only WITH Classpath-exception-2.0 AND BSD-3-Clause"
options="net"
makedepends="apache-ant gradle glib-dev gtk+2.0-dev gtk+3.0-dev"
subpackages="$pkgname-doc $pkgname-demos::noarch"
source="$pkgname-$pkgver.tar.gz::https://github.com/openjdk/jfx21u/archive/refs/tags/${pkgver%_p*}+${pkgver##*_p}.tar.gz
	openjfx.profile
	remove-version-suffix-check.patch"
builddir="$srcdir/jfx21u-${pkgver%_p*}-${pkgver##*_p}"

build() {
	gradle -PRELEASE_SUFFIX="-alpine-r$pkgrel" -PCONF=Release sdk apps
}

check() {
	gradle test -x :web:test
}

package() {
	install -dm755 \
		"$pkgdir"/usr/lib \
		"$pkgdir"/usr/share/doc \
		"$pkgdir"/usr/share/licenses \
		"$pkgdir"/usr/share/"$pkgname"/demo

	cp -a build/sdk/lib "$pkgdir"/usr/lib/"$pkgname"
	cp -a build/sdk/legal "$pkgdir"/usr/share/licenses/"$pkgname"
	for app in apps/*/*; do
		test -d "$app"/dist || continue
		cp -a "$app"/dist "$pkgdir"/usr/share/"$pkgname"/demo/"${app##*/}"
	done

	install -Dm644 "$srcdir"/openjfx.profile "$pkgdir"/etc/profile.d/openjfx.sh
}

demos() {
	pkgdesc="$pkgdesc (demos)"

	amove /usr/share/"$pkgname"/demo
}

sha512sums="
9ef6540e316e461a8cddcc6b99c3659663d3d6911204214afe5330fd238b7112431b70e5d2bc7ad548d41f1d8e22fa8d5342f6135901ae8404a8a4e9fdd718cf  openjfx-21.0.3_p1.tar.gz
41cf37116f748269e74a3333b718a854962088b83c6c56cc2860a21c0d0e24673184cea60502afc5d4cb222de368535c417d93ebe841a75c91c6a88dbb0a5041  openjfx.profile
3757ec908449891567150bc4e0a5b301b0b238d17095c0829f6e1f1dae59260d9b162df031a25a31d4836a200a3e045ca9d79e656e4f1b2165649005345ee7a4  remove-version-suffix-check.patch
"
